<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"yoursite.com","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"flat"},"back2top":{"enable":true,"sidebar":true,"scrollpercent":true},"bookmark":{"enable":true,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="Vue商城二〇二〇年五月二十六日 二〇二〇年五月二十七日 首页布局和·动画效果 Promise 新闻资讯列表页布局和效果 评论功能 图片列表和详情页效果 Mint-UI中按钮组件的使用 Mint-UI中Toast组件的使用  Mint-UI的按需导入组件 介绍MUI MUI的使用 main.js文件的作用 项目的入口文件负责文件的导入  12345678import Vue from &#39;vue&#39;;">
<meta property="og:type" content="article">
<meta property="og:title" content="前端&#x2F;Vue+React+Angular&#x2F;Vue&#x2F;Vue商城">
<meta property="og:url" content="http://yoursite.com/2020/06/25/%E5%89%8D%E7%AB%AF/Vue+React+Angular/Vue/Vue%E5%95%86%E5%9F%8E/index.html">
<meta property="og:site_name" content="heweiliang blog">
<meta property="og:description" content="Vue商城二〇二〇年五月二十六日 二〇二〇年五月二十七日 首页布局和·动画效果 Promise 新闻资讯列表页布局和效果 评论功能 图片列表和详情页效果 Mint-UI中按钮组件的使用 Mint-UI中Toast组件的使用  Mint-UI的按需导入组件 介绍MUI MUI的使用 main.js文件的作用 项目的入口文件负责文件的导入  12345678import Vue from &#39;vue&#39;;">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-06-25T04:56:44.367Z">
<meta property="article:modified_time" content="2020-06-26T07:43:39.776Z">
<meta property="article:author" content="heweiliang">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://yoursite.com/2020/06/25/%E5%89%8D%E7%AB%AF/Vue+React+Angular/Vue/Vue%E5%95%86%E5%9F%8E/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>前端/Vue+React+Angular/Vue/Vue商城 | heweiliang blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="heweiliang blog" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">heweiliang blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
        <li class="menu-item menu-item-schedule">

    <a href="/schedule/" rel="section"><i class="fa fa-fw fa-calendar"></i>日程表</a>

  </li>
        <li class="menu-item menu-item-sitemap">

    <a href="/sitemap.xml" rel="section"><i class="fa fa-fw fa-sitemap"></i>站点地图</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="reading-progress-bar"></div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>

  <a href="https://github.com/yourname" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2020/06/25/%E5%89%8D%E7%AB%AF/Vue+React+Angular/Vue/Vue%E5%95%86%E5%9F%8E/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="heweiliang">
      <meta itemprop="description" content="heweiliang blog">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="heweiliang blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          前端/Vue+React+Angular/Vue/Vue商城<a href="https://github.com/user-name/repo-name/tree/branch-name/subdirectory-name_posts/%E5%89%8D%E7%AB%AF/Vue+React+Angular/Vue/Vue%E5%95%86%E5%9F%8E.md" class="post-edit-link" title="编辑" rel="noopener" target="_blank"><i class="fa fa-pencil"></i></a>
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-06-25 12:56:44" itemprop="dateCreated datePublished" datetime="2020-06-25T12:56:44+08:00">2020-06-25</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-06-26 15:43:39" itemprop="dateModified" datetime="2020-06-26T15:43:39+08:00">2020-06-26</time>
              </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span><br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>8.4k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>8 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="Vue商城"><a href="#Vue商城" class="headerlink" title="Vue商城"></a>Vue商城</h1><p>二〇二〇年五月二十六日</p>
<p>二〇二〇年五月二十七日</p>
<p>首页布局和·动画效果</p>
<p>Promise</p>
<p>新闻资讯列表页布局和效果</p>
<p>评论功能</p>
<p>图片列表和详情页效果</p>
<p>Mint-UI中按钮组件的使用</p>
<p>Mint-UI中Toast组件的使用 </p>
<p>Mint-UI的按需导入组件</p>
<p>介绍MUI</p>
<p>MUI的使用</p>
<p>main.js文件的作用 项目的入口文件负责文件的导入 </p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> Vue <span class="keyword">from</span> <span class="string">'vue'</span>;</span><br><span class="line"><span class="comment">// vue 文件的入口文件</span></span><br><span class="line"><span class="keyword">import</span> app <span class="keyword">from</span> <span class="string">'./App.vue'</span>;</span><br><span class="line"><span class="comment">//mint-ui按需导入</span></span><br><span class="line"><span class="keyword">import</span> &#123; Header &#125; <span class="keyword">from</span> <span class="string">'mint-ui'</span>;</span><br><span class="line">Vue.component(Header.name, Header);</span><br><span class="line"><span class="comment">//mui的代码片段</span></span><br><span class="line"><span class="keyword">import</span> <span class="string">'./lib/mui/css/mui.min.css'</span></span><br></pre></td></tr></table></figure>



<h2 id="MintUI-组件-基于vue-js移动端组件库"><a href="#MintUI-组件-基于vue-js移动端组件库" class="headerlink" title="MintUI 组件 基于vue.js移动端组件库"></a>MintUI 组件 基于vue.js移动端组件库</h2><p>Mint UI 基于Vue,js的移动端组件库 ，饿了么的 MintUI 组件</p>
<p><a href="https://github.com/ElemeFE/mint-ui" target="_blank" rel="noopener">Github 仓储地址</a></p>
<p><a href="http://mint-ui.github.io/#!/zh-cn" target="_blank" rel="noopener">Mint-UI 官方文档</a></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm i mint-ui -S 安装 //vue2.0</span><br></pre></td></tr></table></figure>

<p>导入所有 MintUI 组件</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">main.js</span><br><span class="line"><span class="comment">// 引入全部组件</span></span><br><span class="line"><span class="keyword">import</span> Vue <span class="keyword">from</span> <span class="string">'vue'</span>;</span><br><span class="line"><span class="keyword">import</span> MintUI <span class="keyword">from</span> <span class="string">'mint-ui'</span>; <span class="comment">// 把所有的组件都导入进来</span></span><br><span class="line"><span class="keyword">import</span> <span class="string">'mint-ui/lib/style.css'</span>;<span class="comment">// 可以省略 node_modules 这一层目录 导入样式表</span></span><br><span class="line"><span class="keyword">import</span> App <span class="keyword">from</span> <span class="string">'./App.vue'</span></span><br><span class="line">Vue.use(MintUI); <span class="comment">// 将Mint安装到Vue中 在 vue 中使用 MintUI 中的 Button 按钮和 Toast 弹框提示：</span></span><br><span class="line"><span class="comment">// 把所有的组件，注册为全局的组件</span></span><br><span class="line">app.vue</span><br><span class="line">&lt;mt-button type=<span class="string">"primary"</span> size=<span class="string">"large"</span>&gt;primary&lt;<span class="regexp">/mt-button&gt;</span></span><br></pre></td></tr></table></figure>

<p>按需导入的配置方式</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 按需引入部分组件</span></span><br><span class="line"><span class="keyword">import</span> &#123; Cell, Checklist &#125; <span class="keyword">from</span> <span class="string">'mint-ui'</span>;</span><br><span class="line">Vue.component(Cell.name, Cell);</span><br><span class="line">Vue.component(Checklist.name, Checklist);</span><br><span class="line"></span><br><span class="line">app.vue</span><br><span class="line">&lt;mt-button type=<span class="string">"primary"</span> size=<span class="string">"large"</span>&gt;primary&lt;<span class="regexp">/mt-button&gt;</span></span><br></pre></td></tr></table></figure>

<p>借助 <a href="https://github.com/QingWei-Li/babel-plugin-component" target="_blank" rel="noopener">babel-plugin-component</a>，我们可以只引入需要的组件，以达到减小项目体积的目的。</p>
<p>首先，安装 babel-plugin-component：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">npm install babel-plugin-component -D</span><br><span class="line">&#123;</span><br><span class="line">  <span class="string">"presets"</span>: [<span class="string">"env"</span>, <span class="string">"stage-0"</span>],</span><br><span class="line">  <span class="string">"plugins"</span>: [<span class="string">"transform-runtime"</span>, [<span class="string">"component"</span>, [</span><br><span class="line">    &#123;</span><br><span class="line">      <span class="string">"libraryName"</span>: <span class="string">"mint-ui"</span>,</span><br><span class="line">      <span class="string">"style"</span>: <span class="literal">true</span></span><br><span class="line">    &#125;</span><br><span class="line">  ]]]</span><br><span class="line">&#125;</span><br><span class="line">import &#123; Cell, Checklist &#125; from <span class="string">'mint-ui'</span>;</span><br><span class="line">Vue.component(Cell.name, Cell);</span><br><span class="line">Vue.component(Checklist.name, Checklist);</span><br></pre></td></tr></table></figure>



<h3 id="MUI-代码片段-（停止更新了）"><a href="#MUI-代码片段-（停止更新了）" class="headerlink" title="MUI 代码片段 （停止更新了）"></a>MUI 代码片段 （停止更新了）</h3><blockquote>
<p>注意： MUI 不同于 Mint-UI，MUI 只是开发出来的一套好用的代码片段，里面提供了配套的样式、配套的 HTML 代码段，类似于 Bootstrap； 而 Mint-UI，是真正的组件库，是使用 Vue 技术封装出来的 成套的组件，可以无缝的和 VUE 项目进行集成开发；<br>因此，从体验上来说， Mint-UI 体验更好，因为这是别人帮我们开发好的现成的 Vue 组件；<br>从体验上来说， MUI 和 Bootstrap 类似；<br>理论上，任何项目都可以使用 MUI 或 Bootstrap，但是，MInt-UI 只适用于 Vue 项目；</p>
<p>注意： MUI 并不能使用 npm 去下载，需要自己手动从 github 上，下载现成的包，自己解压出来，然后手动拷贝到项目中使用；</p>
</blockquote>
<p><a href="http://dev.dcloud.net.cn/mui/" target="_blank" rel="noopener">官网首页</a></p>
<p><a href="http://dev.dcloud.net.cn/mui/ui/" target="_blank" rel="noopener">文档地址</a></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F;导入 MUI 的样式表：</span><br><span class="line">import &#39;..&#x2F;lib&#x2F;mui&#x2F;css&#x2F;mui.min.css&#39;</span><br><span class="line">&#x2F;&#x2F;在&#96;webpack.config.js&#96;中添加新的 loader 规则：</span><br><span class="line">&#123; test: &#x2F;\.(png|jpg|gif|ttf)$&#x2F;, use: &#39;url-loader&#39; &#125;</span><br><span class="line">根据官方提供的文档和 example，尝试使用相关的组件</span><br></pre></td></tr></table></figure>

<p>MinUI的组件</p>
<ul>
<li>JS components</li>
<li>CSS components</li>
</ul>
<p>![1 (C:\Users\Administrator\Pictures\壁纸\1 (3).jpg)](C:\Users\Administrator\Pictures\壁纸\1 (3).jpg)</p>
<h3 id="git版本管理工具"><a href="#git版本管理工具" class="headerlink" title="git版本管理工具"></a>git版本管理工具</h3><p><code>.gitignore 项目忽略文件</code></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">node_modules</span><br><span class="line">// 软件的配置文件</span><br><span class="line">.idea</span><br><span class="line">.vscode</span><br><span class="line">.git</span><br></pre></td></tr></table></figure>

<p><code>README.md 项目描述信息的文件</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p><code>LICENSE 开源协议文件</code></p>
<p><a href="https://www.zhihu.com/question/19568896" target="_blank" rel="noopener">主流开源协议之间有何异同</a></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h3 id="将项目源码托管到-oschina-中"><a href="#将项目源码托管到-oschina-中" class="headerlink" title="将项目源码托管到 oschina 中"></a>将项目源码托管到 oschina 中</h3><ol>
<li><p>点击头像 -&gt; 修改资料 -&gt; SSH 公钥  和 <code>git config --global user.email ***@**.com</code> 来全局配置提交时用户的名称和邮箱</p>
</li>
<li><p>使用 <code>git init</code> 在本地初始化项目</p>
</li>
<li><p>使用 <code>touch README.md</code> 和 <code>touch .gitignore</code> 来创建项目的说明文件和忽略文件；</p>
</li>
<li><p>使用 <code>git add .</code> 将所有文件托管到 git 中</p>
</li>
<li><p>使用 <code>git commit -m &quot;init project&quot;</code> 将项目进行本地提交</p>
</li>
<li><p>使用 <code>git remote add origin 仓储地址</code>将本地项目和远程仓储连接，并使用 origin 最为远程仓储的别名</p>
</li>
<li><p>使用 <code>git push -u origin master</code> 将本地代码 push 到仓储中</p>
</li>
</ol>
<h3 id="App-vue-组件的基本设置"><a href="#App-vue-组件的基本设置" class="headerlink" title="App.vue 组件的基本设置"></a>App.vue 组件的基本设置</h3><ol>
<li><p>头部的固定导航栏使用 <code>Mint-UI</code> 的 <code>Header</code> 组件；</p>
</li>
<li><p>底部的页签使用 <code>mui</code> 的 <code>tabbar</code>;</p>
</li>
<li><p>购物车的图标，使用 <code>icons-extra</code> 中的 <code>mui-icon-extra mui-icon-extra-cart</code>，同时，应该把其依赖的字体图标文件 <code>mui-icons-extra.ttf</code>，复制到 <code>fonts</code> 目录下！</p>
</li>
<li><p>将底部的页签，改造成 <code>router-link</code> 来实现单页面的切换；</p>
</li>
<li><p>Tab Bar 路由激活时候设置高亮的两种方式：</p>
</li>
</ol>
<ul>
<li>全局设置样式如下：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">.router-link-active&#123;</span><br><span class="line"></span><br><span class="line">    	color:#007aff !important;</span><br><span class="line"></span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>或者在 <code>new VueRouter</code> 的时候，通过 <code>linkActiveClass</code> 来指定高亮的类：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 创建路由对象</span><br><span class="line"></span><br><span class="line">  var router &#x3D; new VueRouter(&#123;</span><br><span class="line"></span><br><span class="line">    routes: [</span><br><span class="line"></span><br><span class="line">      &#123; path: &#39;&#x2F;&#39;, redirect: &#39;&#x2F;home&#39; &#125;</span><br><span class="line"></span><br><span class="line">    ],</span><br><span class="line"></span><br><span class="line">    linkActiveClass: &#39;mui-active&#39;</span><br><span class="line"></span><br><span class="line">  &#125;);</span><br></pre></td></tr></table></figure>

<h3 id="实现-tabbar-页签不同组件页面的切换"><a href="#实现-tabbar-页签不同组件页面的切换" class="headerlink" title="实现 tabbar 页签不同组件页面的切换"></a>实现 tabbar 页签不同组件页面的切换</h3><ol>
<li><p>将 tabbar 改造成 <code>router-link</code> 形式，并指定每个连接的 <code>to</code> 属性；</p>
</li>
<li><p>在入口文件中导入需要展示的组件，并创建路由对象：</p>
</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 导入需要展示的组件</span><br><span class="line"></span><br><span class="line">import Home from &#39;.&#x2F;components&#x2F;home&#x2F;home.vue&#39;</span><br><span class="line"></span><br><span class="line">import Member from &#39;.&#x2F;components&#x2F;member&#x2F;member.vue&#39;</span><br><span class="line"></span><br><span class="line">import Shopcar from &#39;.&#x2F;components&#x2F;shopcar&#x2F;shopcar.vue&#39;</span><br><span class="line"></span><br><span class="line">import Search from &#39;.&#x2F;components&#x2F;search&#x2F;search.vue&#39;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F; 创建路由对象</span><br><span class="line"></span><br><span class="line">var router &#x3D; new VueRouter(&#123;</span><br><span class="line"></span><br><span class="line">  routes: [</span><br><span class="line"></span><br><span class="line">    &#123; path: &#39;&#x2F;&#39;, redirect: &#39;&#x2F;home&#39; &#125;,</span><br><span class="line"></span><br><span class="line">    &#123; path: &#39;&#x2F;home&#39;, component: Home &#125;,</span><br><span class="line"></span><br><span class="line">    &#123; path: &#39;&#x2F;member&#39;, component: Member &#125;,</span><br><span class="line"></span><br><span class="line">    &#123; path: &#39;&#x2F;shopcar&#39;, component: Shopcar &#125;,</span><br><span class="line"></span><br><span class="line">    &#123; path: &#39;&#x2F;search&#39;, component: Search &#125;</span><br><span class="line"></span><br><span class="line">  ],</span><br><span class="line"></span><br><span class="line">  linkActiveClass: &#39;mui-active&#39;</span><br><span class="line"></span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<h3 id="使用-mt-swipe-轮播图组件"><a href="#使用-mt-swipe-轮播图组件" class="headerlink" title="使用 mt-swipe 轮播图组件"></a>使用 mt-swipe 轮播图组件</h3><ol>
<li>假数据：</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">lunbo: [</span><br><span class="line"></span><br><span class="line">        &#39;http:&#x2F;&#x2F;www.itcast.cn&#x2F;images&#x2F;slidead&#x2F;BEIJING&#x2F;2017440109442800.jpg&#39;,</span><br><span class="line"></span><br><span class="line">        &#39;http:&#x2F;&#x2F;www.itcast.cn&#x2F;images&#x2F;slidead&#x2F;BEIJING&#x2F;2017511009514700.jpg&#39;,</span><br><span class="line"></span><br><span class="line">        &#39;http:&#x2F;&#x2F;www.itcast.cn&#x2F;images&#x2F;slidead&#x2F;BEIJING&#x2F;2017421414422600.jpg&#39;</span><br><span class="line"></span><br><span class="line">      ]</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>引入轮播图组件：</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- Mint-UI 轮播图组件 --&gt;</span><br><span class="line"></span><br><span class="line">    &lt;div class&#x3D;&quot;home-swipe&quot;&gt;</span><br><span class="line"></span><br><span class="line">      &lt;mt-swipe :auto&#x3D;&quot;4000&quot;&gt;</span><br><span class="line"></span><br><span class="line">        &lt;mt-swipe-item v-for&#x3D;&quot;(item, i) in lunbo&quot; :key&#x3D;&quot;i&quot;&gt;</span><br><span class="line"></span><br><span class="line">          &lt;img :src&#x3D;&quot;item&quot; alt&#x3D;&quot;&quot;&gt;</span><br><span class="line"></span><br><span class="line">        &lt;&#x2F;mt-swipe-item&gt;</span><br><span class="line"></span><br><span class="line">      &lt;&#x2F;mt-swipe&gt;</span><br><span class="line"></span><br><span class="line">    &lt;&#x2F;div&gt;</span><br><span class="line"></span><br><span class="line">  &lt;&#x2F;div&gt;</span><br></pre></td></tr></table></figure>

<h3 id="在-vue组件中使用vue-resource获取数据"><a href="#在-vue组件中使用vue-resource获取数据" class="headerlink" title="在.vue组件中使用vue-resource获取数据"></a>在<code>.vue</code>组件中使用<code>vue-resource</code>获取数据</h3><ol>
<li><p>运行<code>cnpm i vue-resource -S</code>安装模块</p>
</li>
<li><p>导入 vue-resource 组件</p>
</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">import VueResource from &#39;vue-resource&#39;</span><br></pre></td></tr></table></figure>

<ol start="3">
<li>在 vue 中使用 vue-resource 组件</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Vue.use(VueResource);</span><br></pre></td></tr></table></figure>

<h3 id="使用-mui-的tab-top-webview-main完成分类滑动栏"><a href="#使用-mui-的tab-top-webview-main完成分类滑动栏" class="headerlink" title="使用 mui 的tab-top-webview-main完成分类滑动栏"></a>使用 mui 的<code>tab-top-webview-main</code>完成分类滑动栏</h3><h3 id="兼容问题"><a href="#兼容问题" class="headerlink" title="兼容问题"></a>兼容问题</h3><ol>
<li>和 App.vue 中的 <code>router-link</code> 身上的类名 <code>mui-tab-item</code> 存在兼容性问题，导致 tab 栏失效，可以把<code>mui-tab-item</code>改名为<code>mui-tab-item1</code>，并复制相关的类样式，来解决这个问题；</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">.mui-bar-tab .mui-tab-item1.mui-active &#123;</span><br><span class="line">  color: #007aff;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">.mui-bar-tab .mui-tab-item1 &#123;</span><br><span class="line">  display: table-cell;</span><br><span class="line">  overflow: hidden;</span><br><span class="line">  width: 1%;</span><br><span class="line">  height: 50px;</span><br><span class="line">  text-align: center;</span><br><span class="line">  vertical-align: middle;</span><br><span class="line">  white-space: nowrap;</span><br><span class="line">  text-overflow: ellipsis;</span><br><span class="line">  color: #929292;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">.mui-bar-tab .mui-tab-item1 .mui-icon &#123;</span><br><span class="line">  top: 3px;</span><br><span class="line">  width: 24px;</span><br><span class="line">  height: 24px;</span><br><span class="line">  padding-top: 0;</span><br><span class="line">  padding-bottom: 0;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">.mui-bar-tab .mui-tab-item1 .mui-icon~.mui-tab-label &#123;</span><br><span class="line">  font-size: 11px;</span><br><span class="line">  display: block;</span><br><span class="line">  overflow: hidden;</span><br><span class="line">  text-overflow: ellipsis;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ol start="2">
<li><code>tab-top-webview-main</code>组件第一次显示到页面中的时候，无法被滑动的解决方案：</li>
</ol>
<ul>
<li>先导入 mui 的 JS 文件:</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">import mui from &#39;..&#x2F;..&#x2F;..&#x2F;lib&#x2F;mui&#x2F;js&#x2F;mui.min.js&#39;</span><br></pre></td></tr></table></figure>

<ul>
<li>在 组件的 <code>mounted</code> 事件钩子中，注册 mui 的滚动事件：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">mounted() &#123;</span><br><span class="line">  	&#x2F;&#x2F; 需要在组件的 mounted 事件钩子中，注册 mui 的 scroll 滚动事件</span><br><span class="line">      mui(&#39;.mui-scroll-wrapper&#39;).scroll(&#123;</span><br><span class="line">        deceleration: 0.0005 &#x2F;&#x2F;flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006</span><br><span class="line">      &#125;);</span><br><span class="line">	&#125;</span><br></pre></td></tr></table></figure>

<ol start="3">
<li>滑动的时候报警告：<code>Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080</code></li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">解决方法，可以加上* &#123; touch-action: pan-y; &#125; 这句样式去掉。</span><br></pre></td></tr></table></figure>

<p>原因：（是 chrome 为了提高页面的滑动流畅度而新折腾出来的一个东西） <a href="http://www.cnblogs.com/pearl07/p/6589114.html" target="_blank" rel="noopener">http://www.cnblogs.com/pearl07/p/6589114.html</a><br><a href="https://developer.mozilla.org/zh-CN/docs/Web/CSS/touch-action" target="_blank" rel="noopener">https://developer.mozilla.org/zh-CN/docs/Web/CSS/touch-action</a></p>
<h2 id="移除严格模式"><a href="#移除严格模式" class="headerlink" title="移除严格模式"></a>移除严格模式</h2><p><a href="https://github.com/genify/babel-plugin-transform-remove-strict-mode" target="_blank" rel="noopener">babel-plugin-transform-remove-strict-mode</a></p>
<p>项目外网测试</p>
<h2 id="开启-Apache-的-gzip-压缩"><a href="#开启-Apache-的-gzip-压缩" class="headerlink" title="开启 Apache 的 gzip 压缩"></a>开启 Apache 的 gzip 压缩</h2><p>要让 apache 支持 gzip 功能，要用到 deflate_Module 和 headers_Module。打开 apache 的配置文件 httpd.conf，大约在 105 行左右，找到以下两行内容：（这两行不是连续在一起的）</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">#LoadModule deflate_module modules&#x2F;mod_deflate.so</span><br><span class="line">#LoadModule headers_module modules&#x2F;mod_headers.so</span><br></pre></td></tr></table></figure>

<p>然后将其前面的“#”注释删掉，表示开启 gzip 压缩功能。开启以后还需要进行相关配置。在 httpd.conf 文件的最后添加以下内容即可：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;IfModule deflate_module&gt;</span><br><span class="line">    #必须的，就像一个开关一样，告诉apache对传输到浏览器的内容进行压缩</span><br><span class="line">    SetOutputFilter DEFLATE</span><br><span class="line">    DeflateCompressionLevel 9</span><br><span class="line">&lt;&#x2F;IfModule&gt;</span><br></pre></td></tr></table></figure>

<p>最少需要加上以上内容，才可以生 gzip 功能生效。由于没有做其它的额外配置，所以其它相关的配置均使用 Apache 的默认设置。这里说一下参数“DeflateCompressionLevel”，它表示压缩级别，值从 1 到 9，值越大表示压缩的越厉害。</p>
<h2 id="使用-ngrok-将本机映射为一个外网的-Web-服务器"><a href="#使用-ngrok-将本机映射为一个外网的-Web-服务器" class="headerlink" title="使用 ngrok 将本机映射为一个外网的 Web 服务器"></a>使用 ngrok 将本机映射为一个外网的 Web 服务器</h2><p>注意：由于默认使用的美国的服务器进行中间转接，所以访问速度炒鸡慢，访问时可启用 FQ 软件，提高网页打开速度！</p>
<h2 id="键盘修饰符以及自定义键盘修饰符"><a href="#键盘修饰符以及自定义键盘修饰符" class="headerlink" title="键盘修饰符以及自定义键盘修饰符"></a>键盘修饰符以及自定义键盘修饰符</h2><h3 id="1-x-中自定义键盘修饰符【了解即可】"><a href="#1-x-中自定义键盘修饰符【了解即可】" class="headerlink" title="1.x 中自定义键盘修饰符【了解即可】"></a>1.x 中自定义键盘修饰符【了解即可】</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Vue.directive(&#39;on&#39;).keyCodes.f2 &#x3D; 113;</span><br></pre></td></tr></table></figure>

<h3 id="2-x-中自定义键盘修饰符"><a href="#2-x-中自定义键盘修饰符" class="headerlink" title="2.x 中自定义键盘修饰符"></a><a href="https://cn.vuejs.org/v2/guide/events.html#键值修饰符" target="_blank" rel="noopener">2.x 中自定义键盘修饰符</a></h3><ol>
<li>通过<code>Vue.config.keyCodes.名称 = 按键值</code>来自定义案件修饰符的别名：</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Vue.config.keyCodes.f2 &#x3D; 113;</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>使用自定义的按键修饰符：</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;input type&#x3D;&quot;text&quot; v-model&#x3D;&quot;name&quot; @keyup.f2&#x3D;&quot;add&quot;&gt;</span><br></pre></td></tr></table></figure>

<h2 id="Vue-js2-0-的新特性"><a href="#Vue-js2-0-的新特性" class="headerlink" title="Vue.js2.0 的新特性"></a>Vue.js2.0 的新特性</h2><h3 id="Render-函数渲染组件"><a href="#Render-函数渲染组件" class="headerlink" title="Render 函数渲染组件"></a>Render 函数渲染组件</h3><h3 id="服务器端渲染"><a href="#服务器端渲染" class="headerlink" title="服务器端渲染"></a>服务器端渲染</h3><h2 id="品牌管理案例"><a href="#品牌管理案例" class="headerlink" title="品牌管理案例"></a>品牌管理案例</h2><h3 id="添加新品牌"><a href="#添加新品牌" class="headerlink" title="添加新品牌"></a>添加新品牌</h3><h3 id="删除品牌"><a href="#删除品牌" class="headerlink" title="删除品牌"></a>删除品牌</h3><h3 id="根据条件筛选品牌"><a href="#根据条件筛选品牌" class="headerlink" title="根据条件筛选品牌"></a>根据条件筛选品牌</h3><ol>
<li>1.x 版本中的filterBy指令，在2.x中已经被废除：</li>
</ol>
<p><a href="https://v1-cn.vuejs.org/api/#filterBy" target="_blank" rel="noopener">filterBy - 指令</a></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">&lt;tr v-for&#x3D;&quot;item in list | filterBy searchName in &#39;name&#39;&quot;&gt;</span><br><span class="line"></span><br><span class="line">  &lt;td&gt;&#123;&#123;item.id&#125;&#125;&lt;&#x2F;td&gt;</span><br><span class="line"></span><br><span class="line">  &lt;td&gt;&#123;&#123;item.name&#125;&#125;&lt;&#x2F;td&gt;</span><br><span class="line"></span><br><span class="line">  &lt;td&gt;&#123;&#123;item.ctime&#125;&#125;&lt;&#x2F;td&gt;</span><br><span class="line"></span><br><span class="line">  &lt;td&gt;</span><br><span class="line"></span><br><span class="line">    &lt;a href&#x3D;&quot;#&quot; @click.prevent&#x3D;&quot;del(item.id)&quot;&gt;删除&lt;&#x2F;a&gt;</span><br><span class="line"></span><br><span class="line">  &lt;&#x2F;td&gt;</span><br><span class="line"></span><br><span class="line">&lt;&#x2F;tr&gt;</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>在2.x版本中<a href="https://cn.vuejs.org/v2/guide/list.html#显示过滤-排序结果" target="_blank" rel="noopener">手动实现筛选的方式</a>：</li>
</ol>
<ul>
<li>筛选框绑定到 VM 实例中的 <code>searchName</code> 属性：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;hr&gt; 输入筛选名称：</span><br><span class="line"></span><br><span class="line">&lt;input type&#x3D;&quot;text&quot; v-model&#x3D;&quot;searchName&quot;&gt;</span><br></pre></td></tr></table></figure>

<ul>
<li>在使用 <code>v-for</code> 指令循环每一行数据的时候，不再直接 <code>item in list</code>，而是 <code>in</code> 一个 过滤的methods 方法，同时，把过滤条件<code>searchName</code>传递进去：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">&lt;tbody&gt;</span><br><span class="line"></span><br><span class="line">      &lt;tr v-for&#x3D;&quot;item in search(searchName)&quot;&gt;</span><br><span class="line"></span><br><span class="line">        &lt;td&gt;&#123;&#123;item.id&#125;&#125;&lt;&#x2F;td&gt;</span><br><span class="line"></span><br><span class="line">        &lt;td&gt;&#123;&#123;item.name&#125;&#125;&lt;&#x2F;td&gt;</span><br><span class="line"></span><br><span class="line">        &lt;td&gt;&#123;&#123;item.ctime&#125;&#125;&lt;&#x2F;td&gt;</span><br><span class="line"></span><br><span class="line">        &lt;td&gt;</span><br><span class="line"></span><br><span class="line">          &lt;a href&#x3D;&quot;#&quot; @click.prevent&#x3D;&quot;del(item.id)&quot;&gt;删除&lt;&#x2F;a&gt;</span><br><span class="line"></span><br><span class="line">        &lt;&#x2F;td&gt;</span><br><span class="line"></span><br><span class="line">      &lt;&#x2F;tr&gt;</span><br><span class="line"></span><br><span class="line">    &lt;&#x2F;tbody&gt;</span><br></pre></td></tr></table></figure>

<ul>
<li><code>search</code> 过滤方法中，使用 数组的 <code>filter</code> 方法进行过滤：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">search(name) &#123;</span><br><span class="line"></span><br><span class="line">  return this.list.filter(x &#x3D;&gt; &#123;</span><br><span class="line"></span><br><span class="line">    return x.name.indexOf(name) !&#x3D; -1;</span><br><span class="line"></span><br><span class="line">  &#125;);</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>###</p>
<p>axios 知识扩展</p>
<a id="more"></a>
    </div>

    
    
    
        <div class="reward-container">
  <div></div>
  <button onclick="var qr = document.getElementById('qr'); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/images/wechatpay.jpg" alt="heweiliang 微信支付">
        <p>微信支付</p>
      </div>
      
      <div style="display: inline-block;">
        <img src="/images/alipay.jpg" alt="heweiliang 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

        

  <div class="followme">
    <p>欢迎关注我的其它发布渠道</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/06/25/%E5%89%8D%E7%AB%AF/Vue+React+Angular/Vue/vue%E5%BC%80%E5%8F%91%E7%BB%84%E4%BB%B6%E5%BA%93/" rel="prev" title="前端/Vue+React+Angular/Vue/vue开发组件库">
      <i class="fa fa-chevron-left"></i> 前端/Vue+React+Angular/Vue/vue开发组件库
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/06/25/%E5%89%8D%E7%AB%AF/JavaScript/Xpath%E6%95%99%E7%A8%8B/" rel="next" title="前端/JavaScript/Xpath教程">
      前端/JavaScript/Xpath教程 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    
  <div class="comments">
    <div id="lv-container" data-id="city" data-uid="MTAyMC81MDY1MC8yNzEzMw=="></div>
  </div>
  

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Vue商城"><span class="nav-number">1.</span> <span class="nav-text">Vue商城</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#MintUI-组件-基于vue-js移动端组件库"><span class="nav-number">1.1.</span> <span class="nav-text">MintUI 组件 基于vue.js移动端组件库</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#MUI-代码片段-（停止更新了）"><span class="nav-number">1.1.1.</span> <span class="nav-text">MUI 代码片段 （停止更新了）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#git版本管理工具"><span class="nav-number">1.1.2.</span> <span class="nav-text">git版本管理工具</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#将项目源码托管到-oschina-中"><span class="nav-number">1.1.3.</span> <span class="nav-text">将项目源码托管到 oschina 中</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#App-vue-组件的基本设置"><span class="nav-number">1.1.4.</span> <span class="nav-text">App.vue 组件的基本设置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实现-tabbar-页签不同组件页面的切换"><span class="nav-number">1.1.5.</span> <span class="nav-text">实现 tabbar 页签不同组件页面的切换</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#使用-mt-swipe-轮播图组件"><span class="nav-number">1.1.6.</span> <span class="nav-text">使用 mt-swipe 轮播图组件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#在-vue组件中使用vue-resource获取数据"><span class="nav-number">1.1.7.</span> <span class="nav-text">在.vue组件中使用vue-resource获取数据</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#使用-mui-的tab-top-webview-main完成分类滑动栏"><span class="nav-number">1.1.8.</span> <span class="nav-text">使用 mui 的tab-top-webview-main完成分类滑动栏</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#兼容问题"><span class="nav-number">1.1.9.</span> <span class="nav-text">兼容问题</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#移除严格模式"><span class="nav-number">1.2.</span> <span class="nav-text">移除严格模式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#开启-Apache-的-gzip-压缩"><span class="nav-number">1.3.</span> <span class="nav-text">开启 Apache 的 gzip 压缩</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#使用-ngrok-将本机映射为一个外网的-Web-服务器"><span class="nav-number">1.4.</span> <span class="nav-text">使用 ngrok 将本机映射为一个外网的 Web 服务器</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#键盘修饰符以及自定义键盘修饰符"><span class="nav-number">1.5.</span> <span class="nav-text">键盘修饰符以及自定义键盘修饰符</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-x-中自定义键盘修饰符【了解即可】"><span class="nav-number">1.5.1.</span> <span class="nav-text">1.x 中自定义键盘修饰符【了解即可】</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-x-中自定义键盘修饰符"><span class="nav-number">1.5.2.</span> <span class="nav-text">2.x 中自定义键盘修饰符</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Vue-js2-0-的新特性"><span class="nav-number">1.6.</span> <span class="nav-text">Vue.js2.0 的新特性</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Render-函数渲染组件"><span class="nav-number">1.6.1.</span> <span class="nav-text">Render 函数渲染组件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#服务器端渲染"><span class="nav-number">1.6.2.</span> <span class="nav-text">服务器端渲染</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#品牌管理案例"><span class="nav-number">1.7.</span> <span class="nav-text">品牌管理案例</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#添加新品牌"><span class="nav-number">1.7.1.</span> <span class="nav-text">添加新品牌</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#删除品牌"><span class="nav-number">1.7.2.</span> <span class="nav-text">删除品牌</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#根据条件筛选品牌"><span class="nav-number">1.7.3.</span> <span class="nav-text">根据条件筛选品牌</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="heweiliang"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">heweiliang</p>
  <div class="site-description" itemprop="description">heweiliang blog</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">96</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">18</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">24</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/yourname" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;yourname" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i></a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:yourname@gmail.com" title="E-Mail → mailto:yourname@gmail.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i></a>
      </span>
      <span class="links-of-author-item">
        <a href="https://plus.google.com/yourname" title="Google → https:&#x2F;&#x2F;plus.google.com&#x2F;yourname" rel="noopener" target="_blank"><i class="fa fa-fw fa-google"></i></a>
      </span>
      <span class="links-of-author-item">
        <a href="https://stackoverflow.com/yourname" title="StackOverflow → https:&#x2F;&#x2F;stackoverflow.com&#x2F;yourname" rel="noopener" target="_blank"><i class="fa fa-fw fa-stack-overflow"></i></a>
      </span>
  </div>
  <div class="cc-license motion-element" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" rel="noopener" target="_blank"><img src="/images/cc-by-nc-sa.svg" alt="Creative Commons"></a>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title">
      <i class="fa fa-fw fa-link"></i>
      Links
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="http://yoursite.com/" title="http:&#x2F;&#x2F;yoursite.com">Title</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="http://yoursite.com/" title="http:&#x2F;&#x2F;yoursite.com">Title2</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="http://yoursite.com/" title="http:&#x2F;&#x2F;yoursite.com">Title3</a>
        </li>
    </ul>
  </div>

      </div>
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">heweiliang</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    <span title="站点总字数">376k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">5:42</span>
</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>

<script src="/js/bookmark.js"></script>


  <script defer src="/lib/three/three.min.js"></script>
    <script defer src="/lib/three/three-waves.min.js"></script>
    <script defer src="/lib/three/canvas_lines.min.js"></script>


  




  
<script src="/js/local-search.js"></script>













  

  

<script>
NexT.utils.loadComments(document.querySelector('#lv-container'), () => {
  window.livereOptions = {
    refer: location.pathname.replace(CONFIG.root, '').replace('index.html', '')
  };
  (function(d, s) {
    var j, e = d.getElementsByTagName(s)[0];
    if (typeof LivereTower === 'function') { return; }
    j = d.createElement(s);
    j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
    j.async = true;
    e.parentNode.insertBefore(j, e);
  })(document, 'script');
});
</script>

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginModelPath":"assets/","model":{"jsonPath":"/live2dw/assets/Epsilon2.1.model.json"},"display":{"position":"left","width":300,"height":600},"mobile":{"show":false},"log":false,"pluginJsPath":"lib/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
